<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
    <title>ShellCheck: SC2114 – Warning: deletes a system directory.</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
  </head>
  <body style="margin-left: auto; margin-right: auto; max-width: 800px">
    <h1>SC2114 – ShellCheck Wiki</h1>
    <a href="https://github.com/koalaman/shellcheck/wiki/SC2114">See this page on GitHub</a>
    <p style="display: none"><a href="index.html">Sitemap</a></p>
    <hr />
    <h2 id="warning-deletes-a-system-directory">Warning: deletes a system
directory.</h2>
<h3 id="problematic-code">Problematic code:</h3>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="SC2114.html#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">rm</span> <span class="at">-rf</span> /usr /lib/nvidia-current/xorg/xorg</span></code></pre></div>
<h3 id="correct-code">Correct code:</h3>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="SC2114.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">rm</span> <span class="at">-rf</span> /usr/lib/nvidia-current/xorg/xorg</span></code></pre></div>
<h3 id="rationale">Rationale:</h3>
<p>The example line of code was an actual bug in the <a
href="https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/commit/a047be85247755cdbe0acce6f1dafc8beb84f2ac">Bumblebee
NVIDIA driver</a>.</p>
<p>Due to an accidental space, it deleted <code>/usr</code> instead of
just the particular directory.</p>
<h3 id="exceptions">Exceptions:</h3>
<p>If you do intend to delete a system directory, such as when working
in a chroot or initramfs, you can disable this message with a
directive:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="SC2114.html#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># shellcheck disable=SC2114</span></span>
<span id="cb3-2"><a href="SC2114.html#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="fu">rm</span> <span class="at">-rf</span> /usr </span></code></pre></div>
<p>Previous versions of shellcheck, up to and including 0.4.6, would
ignore <code>rm</code> statements containing a <code>--</code> (an
arbitrary convention). This is no longer the case.</p>
    <hr />
    <p style='font-size: 80%'><a href="../index.html">ShellCheck</a> is a static analysis tool for shell scripts. This page is part of its documentation.</p>
  </body>
</html>


